package org.example.service;

import org.example.vo.SecurityUser;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @Author：无敌暴龙战士
 * @Package：org.example.service
 * @Project：learn_spring_security
 * @name：UserDetailsServiceImpl
 * @Date：2025/2/13 0:58
 * @Filename：UserDetailsServiceImpl
 * @Description:
 */
@Service
public class UserDetailsServiceImpl implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        if (!StringUtils.hasText(username)) {//如果用户名null
            throw new UsernameNotFoundException("your username is not be found");
        }
        if (username.equals("thomas")) {
            throw new UsernameNotFoundException("your username is not right");
        }
        SecurityUser securityUser = new SecurityUser();
        return securityUser;
    }
}
